home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** Header for routines demonstrating how to read resource files without
- ** using the Resource Manager.
- **
- ** by Mark Cookson, Apple Developer Technical Support
- **
- ** File: ReadResource.h
- **
- ** Copyright ©1996 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "Apple Sample
- ** Code" after having made changes. If you're going to re-distribute the
- ** source, we require that you make it clear in the source that the code
- ** was descended from Apple Sample Code, but that you've made changes.
- */
-
- #ifndef __READRESOURCE__
- #define __READRESOURCE__
-
- #include <Errors.h>
- #include <Resources.h>
-
- #ifndef __DEFINES__
- #include "Defines.h"
- #endif
-
- struct ResourceHeader {
- long resDataOffset;
- long resMapOffset;
- long resDataLength;
- long resMapLength;
- };
- typedef struct ResourceHeader ResourceHeader;
-
- struct ResourceMap {
- unsigned char reserved1[16];//for copy of resource header
- long reserved2;//for handle to next resource map
- short reserved3;//for file reference number
- short resFileAttrs;
- unsigned short typesListOffset;
- unsigned short namesListOffset;
- unsigned short numTypesInMap;
- };
- typedef struct ResourceMap ResourceMap;
-
- struct ResourceTypeListEntry {
- OSType resType;
- unsigned short numEntries;
- unsigned short referenceOffset;
- };
- typedef struct ResourceTypeListEntry ResourceTypeListEntry;
-
- struct ResReference {
- short ID;
- unsigned short nameOffset;
- long dataOffset;//high byte is actually resource attributes, low three bytes are offset to beginning of data
- long reserved;//for handle to resource
- };
- typedef struct ResReference ResReference;
-
- OSErr MyGetFirstResource (short refNum,
- OSType targetType,
- short *targetID);
-
- OSErr MyGetResourcePosition (short refNum,
- OSType targetType,
- short targetID,
- long *firstByte);
-
- OSErr MyGetTypesPosition (short refNum,
- OSType theType,
- short *numResources,
- long *dataOffset,
- long *firstByteOfTypeList);
-
- #endif